package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shop.pojo.GoodsDescriptionPicture;
import com.example.shop.pojo.GoodsDetailsPicture;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsDetailsPictureMapper extends BaseMapper<GoodsDetailsPicture> {
    @Select("select * from r_goods_details_picture where goods_id = #{goodsId}")
    List<GoodsDescriptionPicture> selectById(Long goodsId);

    @Select("select goods_details_picture from r_goods_details_picture where goods_id = #{goodsId}")
    List<String> selectPictureById(Long goodId);

    @Insert("<script>" +
            "insert r_goods_details_picture(goods_id,goods_details_picture) " +
            "VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(${item.goodsId},#{item.goodsDetailsPicture})" +
            "</foreach>" +
            "</script>")
    int batchInsert(@Param("list") List<GoodsDetailsPicture> list);

    @Insert("<script>" +
            "insert r_goods_details_picture(goods_id,goods_details_picture) " +
            "VALUES " +
            "<foreach collection='list' item='goodsDetailsPicture' separator=','>" +
            "(${goodsId},#{goodsDetailsPicture})" +
            "</foreach>" +
            "</script>")
    int insertList(@Param("goodsId")long goodsId,@Param("list") List<String> list);


}
